package com.eastfair.point.service.impl;

import com.alibaba.fastjson.JSON;
import com.eastfair.cache.repository.CachePlusOps;
import com.eastfair.point.point.CardTransaction;
import com.eastfair.point.service.CardService;
import com.eastfair.point.service.StoreService;
import com.eastfair.transaction.mq.service.AbstractBaseTransactionService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.core.RocketMQLocalTransactionState;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;


/**
 * <p>
 * 广播处理事件
 *
 * @author ligang
 * @date 2021-08-10
 */
@Slf4j
@Service
public class CardServiceImpl<T> extends AbstractBaseTransactionService<CardTransaction> implements CardService<CardTransaction> {
    @Autowired
    private CachePlusOps cachePlusOps;

    @Override
    public RocketMQLocalTransactionState executeCommit(CardTransaction cardTransaction) {
        log.info("card 本地事务执行 " + JSON.toJSONString(cardTransaction));
        return RocketMQLocalTransactionState.COMMIT;
    }

    @Override
    public RocketMQLocalTransactionState backTransaction(CardTransaction cardTransaction) {
        log.info("card 本地事务回查 " + JSON.toJSONString(cardTransaction));
        return RocketMQLocalTransactionState.COMMIT;
    }

    @Override
    public void executeBusinOfReceiveMsg(CardTransaction cardTransaction) {
        //收到mq消息，生成积分
        executeCommit(cardTransaction);
    }
}
